package com.industrial.white.handler;

import com.industrial.system.api.domain.SysDictData;
import com.industrial.white.domain.WhiteIndustrialArea;
import com.industrial.white.mapper.WhiteIndustrialAreaMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.List;

@Component
public class LoadAdData {

    @Autowired
    private WhiteIndustrialAreaMapper whiteIndustrialAreaMapper;

    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    @PostConstruct
    public void init(){
        List<WhiteIndustrialArea> sysAreas = whiteIndustrialAreaMapper.queryAdDataNoSubString();
        for(WhiteIndustrialArea sysArea : sysAreas){
            redisTemplate.opsForHash().put("adn",sysArea.getAreaCode(),sysArea.getBaseName());
        }


        for(WhiteIndustrialArea sysArea : sysAreas){
            redisTemplate.opsForHash().put("adnbaseid",sysArea.getBaseId(),sysArea.getBaseName());
        }
        System.out.println("加载数行政区数据完成");
    }

}



